/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package cn.com.ly.util;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import org.springframework.context.ApplicationContext;
import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;

/**
 *
 * @author ly
 */
public class SpringInit implements ServletContextListener {

    private static WebApplicationContext springContext;

    public SpringInit() {
        super();
    }

    @Override
    public void contextInitialized(ServletContextEvent event) {
        springContext = WebApplicationContextUtils.getWebApplicationContext(event.getServletContext());

    }

    @Override
    public void contextDestroyed(ServletContextEvent event) {
    }

    public static ApplicationContext getApplicationContext() {
        return springContext;
    }
}
